package com.swe727.spring2011.constraint1.client.util;
import java.math.*;
import java.util.Random;
/* 
 * Class: LogNormalDistribution
 * Author: Fernando Boccanera
 * Function: Generate a random double that follows a log-normal distribution
 */
public class LogNormalDistribution {
	Random RANDOM; 
	double AVERAGE; 
	
	/* 
	 * Constructor requires the average as parameter
	 */
	public LogNormalDistribution(double average) {
		AVERAGE = average;
		RANDOM = new Random(System.currentTimeMillis());  
	}
	
	/* 
	 * Generates the next log-normal point in seconds
	 */
	public double nextLogNormal() {
		double seconds = Math.exp(RANDOM.nextGaussian()/2 + Math.log(AVERAGE));
		return seconds;
	}
}
